// 获取当前城市
export const getCurPosition = function () {
  return new Promise((resolve, reject) => {
    const myCity = new window.BMap.LocalCity()
    myCity.get(
      (result) => {
        const geoc = new window.BMap.Geocoder()
        geoc.getLocation(result.center, (rs) => {
          // rs 中携带着所有的定位信息，这里只获取了城市(city)和所在的区(district)
          const addComp = rs.addressComponents
          const result = addComp.province + addComp.city + addComp.district
          resolve(result)
        })
      },
      { enableHighAccuracy: true }
    )
  })
}
